export function isIOS() {
	return uni.getSystemInfoSync().platform == 'ios';
}

export function launchAppMiniProgram({
	appId,
	path
}) {
	plus.share.getServices(function(res) {
		var sweixin = null;
		for (var i = 0; i < res.length; i++) {
			var t = res[i];
			if (t.id == 'weixin') {
				sweixin = t;
			}
		}

		if (sweixin) {
			sweixin.launchMiniProgram({
				id: appId,
				path: path,
				type: 0
			});
		}
	}, function(res) {
		console.log(JSON.stringify(res));
	});
}

export function launchMiniProgram({
	appId,
	path
}) {
	console.log("launchMiniProgram:",appId,path)
	launchAppMiniProgram({
		appId,
		path
	});
	return
	// #ifdef APP-PLUS
	// 如果是ios 需要先login 然后在 执行下面的代码 isIOS 这个方法根据你项目中的来定义 即可
	if (isIOS()) {
		uni.login({
			provider: 'weixin',
			success: function(loginRes1) {
				launchAppMiniProgram({
					appId,
					path
				});
			}
		});
	} else {
		launchAppMiniProgram({
			appId,
			path
		});
	}
	//#endif
}
